// $ANTLR 3.4 D:\\work\\antlr\\Expr.g 2012-04-08 11:38:45
package com.antlr.sample;

import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;

import org.antlr.runtime.tree.*;


@SuppressWarnings({"all", "warnings", "unchecked"})
public class ExprParser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "DIV", "DOUBLE", "EXPONENT", "INT", "MINUS", "MULT", "PLUS", "WHITESPACE", "'('", "')'", "';'"
    };

    public static final int EOF=-1;
    public static final int T__12=12;
    public static final int T__13=13;
    public static final int T__14=14;
    public static final int DIV=4;
    public static final int DOUBLE=5;
    public static final int EXPONENT=6;
    public static final int INT=7;
    public static final int MINUS=8;
    public static final int MULT=9;
    public static final int PLUS=10;
    public static final int WHITESPACE=11;

    // delegates
    public Parser[] getDelegates() {
        return new Parser[] {};
    }

    // delegators


    public ExprParser(TokenStream input) {
        this(input, new RecognizerSharedState());
    }
    public ExprParser(TokenStream input, RecognizerSharedState state) {
        super(input, state);
    }

protected TreeAdaptor adaptor = new CommonTreeAdaptor();

public void setTreeAdaptor(TreeAdaptor adaptor) {
    this.adaptor = adaptor;
}
public TreeAdaptor getTreeAdaptor() {
    return adaptor;
}
    public String[] getTokenNames() { return ExprParser.tokenNames; }
    public String getGrammarFileName() { return "D:\\work\\antlr\\Expr.g"; }


    public static class statments_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };


    // $ANTLR start "statments"
    // D:\\work\\antlr\\Expr.g:16:1: statments : expr ';' !;
    public final ExprParser.statments_return statments() throws RecognitionException {
        ExprParser.statments_return retval = new ExprParser.statments_return();
        retval.start = input.LT(1);


        Object root_0 = null;

        Token char_literal2=null;
        ExprParser.expr_return expr1 =null;


        Object char_literal2_tree=null;

        try {
            // D:\\work\\antlr\\Expr.g:16:11: ( expr ';' !)
            // D:\\work\\antlr\\Expr.g:17:5: expr ';' !
            {
            root_0 = (Object)adaptor.nil();


            pushFollow(FOLLOW_expr_in_statments65);
            expr1=expr();

            state._fsp--;

            adaptor.addChild(root_0, expr1.getTree());

            char_literal2=(Token)match(input,14,FOLLOW_14_in_statments67); 

            }

            retval.stop = input.LT(-1);


            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }

        finally {
        	// do for sure before leaving
        }
        return retval;
    }
    // $ANTLR end "statments"


    public static class expr_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };


    // $ANTLR start "expr"
    // D:\\work\\antlr\\Expr.g:20:1: expr : mult_div_expr ( ( PLUS ^| MINUS ^) mult_div_expr )* ;
    public final ExprParser.expr_return expr() throws RecognitionException {
        ExprParser.expr_return retval = new ExprParser.expr_return();
        retval.start = input.LT(1);


        Object root_0 = null;

        Token PLUS4=null;
        Token MINUS5=null;
        ExprParser.mult_div_expr_return mult_div_expr3 =null;

        ExprParser.mult_div_expr_return mult_div_expr6 =null;


        Object PLUS4_tree=null;
        Object MINUS5_tree=null;

        try {
            // D:\\work\\antlr\\Expr.g:20:6: ( mult_div_expr ( ( PLUS ^| MINUS ^) mult_div_expr )* )
            // D:\\work\\antlr\\Expr.g:21:5: mult_div_expr ( ( PLUS ^| MINUS ^) mult_div_expr )*
            {
            root_0 = (Object)adaptor.nil();


            pushFollow(FOLLOW_mult_div_expr_in_expr87);
            mult_div_expr3=mult_div_expr();

            state._fsp--;

            adaptor.addChild(root_0, mult_div_expr3.getTree());

            // D:\\work\\antlr\\Expr.g:21:19: ( ( PLUS ^| MINUS ^) mult_div_expr )*
            loop2:
            do {
                int alt2=2;
                int LA2_0 = input.LA(1);

                if ( (LA2_0==MINUS||LA2_0==PLUS) ) {
                    alt2=1;
                }


                switch (alt2) {
            	case 1 :
            	    // D:\\work\\antlr\\Expr.g:21:20: ( PLUS ^| MINUS ^) mult_div_expr
            	    {
            	    // D:\\work\\antlr\\Expr.g:21:20: ( PLUS ^| MINUS ^)
            	    int alt1=2;
            	    int LA1_0 = input.LA(1);

            	    if ( (LA1_0==PLUS) ) {
            	        alt1=1;
            	    }
            	    else if ( (LA1_0==MINUS) ) {
            	        alt1=2;
            	    }
            	    else {
            	        NoViableAltException nvae =
            	            new NoViableAltException("", 1, 0, input);

            	        throw nvae;

            	    }
            	    switch (alt1) {
            	        case 1 :
            	            // D:\\work\\antlr\\Expr.g:21:21: PLUS ^
            	            {
            	            PLUS4=(Token)match(input,PLUS,FOLLOW_PLUS_in_expr91); 
            	            PLUS4_tree = 
            	            (Object)adaptor.create(PLUS4)
            	            ;
            	            root_0 = (Object)adaptor.becomeRoot(PLUS4_tree, root_0);


            	            }
            	            break;
            	        case 2 :
            	            // D:\\work\\antlr\\Expr.g:21:29: MINUS ^
            	            {
            	            MINUS5=(Token)match(input,MINUS,FOLLOW_MINUS_in_expr96); 
            	            MINUS5_tree = 
            	            (Object)adaptor.create(MINUS5)
            	            ;
            	            root_0 = (Object)adaptor.becomeRoot(MINUS5_tree, root_0);


            	            }
            	            break;

            	    }


            	    pushFollow(FOLLOW_mult_div_expr_in_expr100);
            	    mult_div_expr6=mult_div_expr();

            	    state._fsp--;

            	    adaptor.addChild(root_0, mult_div_expr6.getTree());

            	    }
            	    break;

            	default :
            	    break loop2;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);


            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }

        finally {
        	// do for sure before leaving
        }
        return retval;
    }
    // $ANTLR end "expr"


    public static class mult_div_expr_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };


    // $ANTLR start "mult_div_expr"
    // D:\\work\\antlr\\Expr.g:25:1: mult_div_expr : item ( ( MULT ^| DIV ^) item )* ;
    public final ExprParser.mult_div_expr_return mult_div_expr() throws RecognitionException {
        ExprParser.mult_div_expr_return retval = new ExprParser.mult_div_expr_return();
        retval.start = input.LT(1);


        Object root_0 = null;

        Token MULT8=null;
        Token DIV9=null;
        ExprParser.item_return item7 =null;

        ExprParser.item_return item10 =null;


        Object MULT8_tree=null;
        Object DIV9_tree=null;

        try {
            // D:\\work\\antlr\\Expr.g:25:15: ( item ( ( MULT ^| DIV ^) item )* )
            // D:\\work\\antlr\\Expr.g:26:5: item ( ( MULT ^| DIV ^) item )*
            {
            root_0 = (Object)adaptor.nil();


            pushFollow(FOLLOW_item_in_mult_div_expr123);
            item7=item();

            state._fsp--;

            adaptor.addChild(root_0, item7.getTree());

            // D:\\work\\antlr\\Expr.g:26:10: ( ( MULT ^| DIV ^) item )*
            loop4:
            do {
                int alt4=2;
                int LA4_0 = input.LA(1);

                if ( (LA4_0==DIV||LA4_0==MULT) ) {
                    alt4=1;
                }


                switch (alt4) {
            	case 1 :
            	    // D:\\work\\antlr\\Expr.g:26:11: ( MULT ^| DIV ^) item
            	    {
            	    // D:\\work\\antlr\\Expr.g:26:11: ( MULT ^| DIV ^)
            	    int alt3=2;
            	    int LA3_0 = input.LA(1);

            	    if ( (LA3_0==MULT) ) {
            	        alt3=1;
            	    }
            	    else if ( (LA3_0==DIV) ) {
            	        alt3=2;
            	    }
            	    else {
            	        NoViableAltException nvae =
            	            new NoViableAltException("", 3, 0, input);

            	        throw nvae;

            	    }
            	    switch (alt3) {
            	        case 1 :
            	            // D:\\work\\antlr\\Expr.g:26:12: MULT ^
            	            {
            	            MULT8=(Token)match(input,MULT,FOLLOW_MULT_in_mult_div_expr127); 
            	            MULT8_tree = 
            	            (Object)adaptor.create(MULT8)
            	            ;
            	            root_0 = (Object)adaptor.becomeRoot(MULT8_tree, root_0);


            	            }
            	            break;
            	        case 2 :
            	            // D:\\work\\antlr\\Expr.g:26:20: DIV ^
            	            {
            	            DIV9=(Token)match(input,DIV,FOLLOW_DIV_in_mult_div_expr132); 
            	            DIV9_tree = 
            	            (Object)adaptor.create(DIV9)
            	            ;
            	            root_0 = (Object)adaptor.becomeRoot(DIV9_tree, root_0);


            	            }
            	            break;

            	    }


            	    pushFollow(FOLLOW_item_in_mult_div_expr136);
            	    item10=item();

            	    state._fsp--;

            	    adaptor.addChild(root_0, item10.getTree());

            	    }
            	    break;

            	default :
            	    break loop4;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);


            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }

        finally {
        	// do for sure before leaving
        }
        return retval;
    }
    // $ANTLR end "mult_div_expr"


    public static class item_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };


    // $ANTLR start "item"
    // D:\\work\\antlr\\Expr.g:29:1: item : ( INT | DOUBLE | '(' ! expr ')' !);
    public final ExprParser.item_return item() throws RecognitionException {
        ExprParser.item_return retval = new ExprParser.item_return();
        retval.start = input.LT(1);


        Object root_0 = null;

        Token INT11=null;
        Token DOUBLE12=null;
        Token char_literal13=null;
        Token char_literal15=null;
        ExprParser.expr_return expr14 =null;


        Object INT11_tree=null;
        Object DOUBLE12_tree=null;
        Object char_literal13_tree=null;
        Object char_literal15_tree=null;

        try {
            // D:\\work\\antlr\\Expr.g:29:6: ( INT | DOUBLE | '(' ! expr ')' !)
            int alt5=3;
            switch ( input.LA(1) ) {
            case INT:
                {
                alt5=1;
                }
                break;
            case DOUBLE:
                {
                alt5=2;
                }
                break;
            case 12:
                {
                alt5=3;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 5, 0, input);

                throw nvae;

            }

            switch (alt5) {
                case 1 :
                    // D:\\work\\antlr\\Expr.g:30:7: INT
                    {
                    root_0 = (Object)adaptor.nil();


                    INT11=(Token)match(input,INT,FOLLOW_INT_in_item161); 
                    INT11_tree = 
                    (Object)adaptor.create(INT11)
                    ;
                    adaptor.addChild(root_0, INT11_tree);


                    }
                    break;
                case 2 :
                    // D:\\work\\antlr\\Expr.g:31:7: DOUBLE
                    {
                    root_0 = (Object)adaptor.nil();


                    DOUBLE12=(Token)match(input,DOUBLE,FOLLOW_DOUBLE_in_item169); 
                    DOUBLE12_tree = 
                    (Object)adaptor.create(DOUBLE12)
                    ;
                    adaptor.addChild(root_0, DOUBLE12_tree);


                    }
                    break;
                case 3 :
                    // D:\\work\\antlr\\Expr.g:32:7: '(' ! expr ')' !
                    {
                    root_0 = (Object)adaptor.nil();


                    char_literal13=(Token)match(input,12,FOLLOW_12_in_item177); 

                    pushFollow(FOLLOW_expr_in_item180);
                    expr14=expr();

                    state._fsp--;

                    adaptor.addChild(root_0, expr14.getTree());

                    char_literal15=(Token)match(input,13,FOLLOW_13_in_item182); 

                    }
                    break;

            }
            retval.stop = input.LT(-1);


            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }

        finally {
        	// do for sure before leaving
        }
        return retval;
    }
    // $ANTLR end "item"

    // Delegated rules


 

    public static final BitSet FOLLOW_expr_in_statments65 = new BitSet(new long[]{0x0000000000004000L});
    public static final BitSet FOLLOW_14_in_statments67 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_mult_div_expr_in_expr87 = new BitSet(new long[]{0x0000000000000502L});
    public static final BitSet FOLLOW_PLUS_in_expr91 = new BitSet(new long[]{0x00000000000010A0L});
    public static final BitSet FOLLOW_MINUS_in_expr96 = new BitSet(new long[]{0x00000000000010A0L});
    public static final BitSet FOLLOW_mult_div_expr_in_expr100 = new BitSet(new long[]{0x0000000000000502L});
    public static final BitSet FOLLOW_item_in_mult_div_expr123 = new BitSet(new long[]{0x0000000000000212L});
    public static final BitSet FOLLOW_MULT_in_mult_div_expr127 = new BitSet(new long[]{0x00000000000010A0L});
    public static final BitSet FOLLOW_DIV_in_mult_div_expr132 = new BitSet(new long[]{0x00000000000010A0L});
    public static final BitSet FOLLOW_item_in_mult_div_expr136 = new BitSet(new long[]{0x0000000000000212L});
    public static final BitSet FOLLOW_INT_in_item161 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_DOUBLE_in_item169 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_12_in_item177 = new BitSet(new long[]{0x00000000000010A0L});
    public static final BitSet FOLLOW_expr_in_item180 = new BitSet(new long[]{0x0000000000002000L});
    public static final BitSet FOLLOW_13_in_item182 = new BitSet(new long[]{0x0000000000000002L});

}